Test a Perceptual Phenomenon - Stroop data

Katie Truong


In [7]:
import pandas as pd
import numpy as np
import scipy.stats as st
import matplotlib.pyplot as plt
import seaborn as sns
import math

Introduction

In a Stroop experiment, participants are shown two lists of word of color names, printed in different ink colors, and asked to read out loud the ink color that the word was printed. The two lists are the congruent one, where the ink colors of the words agree with the words, and the incongruent one, where the ink colors don't match with the words.

Hypothesis:

The independent variable in this case would be whether the list is a congruent or an incogruent one, while the dependent variable would be the time it takes for participants to name the ink colors.

Now looking at the dataset provided for the experiment:


In [8]:
stroopdata = pd.read_csv("stroopdata.csv")
stroopdata


Out[8]:
Congruent Incongruent
0 12.079 19.278
1 16.791 18.741
2 9.564 21.214
3 8.630 15.687
4 14.669 22.803
5 12.238 20.878
6 14.692 24.572
7 8.987 17.394
8 9.401 20.762
9 14.480 26.282
10 22.328 24.524
11 15.298 18.644
12 15.073 17.510
13 16.929 20.330
14 18.200 35.255
15 12.130 22.158
16 18.495 25.139
17 10.639 20.429
18 11.344 17.425
19 12.369 34.288
20 12.944 23.894
21 14.233 17.960
22 19.710 22.058
23 16.004 21.157

Firstly, assume the distribution of stimulus time for both congruent and incongruent lists are approximately normal, so we would be able to use Z-test or t-test. Secondly, we can see that we have a limited number of samples (24 and under 30), so we should use t-test instead of Z-test. Last but not least, the stimulus times are in pairs for both congruent and incongruent, and not independent events, so a pairwise t-test is our best bet.

Our goal is to determine whether the condition of the list would affect the stimulus time, or the mean stimulus time of each list would be significant different from each other. In other word, let's $\mu_D$, $\mu_I$ and $\mu_C$ be the mean difference between the two lists, the mean of the incongruent and the mean of the congruent, we have:

$$ H_0:\mu_D = \mu_I - \mu_C = 0 $$
$$ H_a:\mu_D = \mu_I - \mu_C \neq 0 $$

The null hypothesis is that there is no significant difference in the population average amount of time it takes to state the colors of the words in a congruent or incongruent condition. If $\mu_D$ is significantly different than 0, we can reject the null hypothesis and conclude that the stimulus time wouldn't be affected by the condition of the list. Otherwise, if $\mu_D$ is not diffent than zero then the condition of the list has no significant effect on the stimulus time. We use $\alpha = 0.05$ .

Before conducting the t-test, it would be beneficial for us to explore the dataset and its discriptive statistics.

Data exploration:

Descriptive statistics of stimulus time of the congruent list:


In [62]:
stroopdata.describe()


Out[62]:
Congruent Incongruent
count 24.000000 24.000000
mean 14.051125 22.015917
std 3.559358 4.797057
min 8.630000 15.687000
25% 11.895250 18.716750
50% 14.356500 21.017500
75% 16.200750 24.051500
max 22.328000 35.255000

We can see that the incongruent group has higher mean, max and standard deviation comparing to the congruent list.

Now we can start plotting the data. The scatterplot of stimulus time of the congruent list in respective with the incongruent list shows a clear trend of the dataset that, in a pair, the incongurent stimulus time would always be higher than the congruent stimulus time.


In [38]:
sns.lmplot(x = 'Congruent', y = 'Incongruent', data = stroopdata)
plt.title("Stimulus times of congruent and incongruent conditions")
plt.xlabel("Congruent list (sec)")
plt.ylabel("Incongruent list (sec)")
plt.show()



In [4]:
fig, ax = plt.subplots()
ax.hist([stroopdata['Congruent'], stroopdata['Incongruent']], label = ['Congruent', 'Incongruent'])
ax.legend()
plt.title('Histogram of stimulus time per condition')
plt.xlabel ("Stimulus time (sec)")
plt.ylabel("Frequency")
plt.show()


Both the scatterplot and the histogram suggest that the incongruent have a longer stimulus time comparing to the congruent list.

t-test:

We can perform the t-test easily using the scipy package:


In [32]:
ttest = st.ttest_rel(stroopdata['Incongruent'], stroopdata['Congruent'])
print(ttest)


Ttest_relResult(statistic=8.020706944109957, pvalue=4.1030005857111781e-08)

With the p-value is pvalue = 4.1003-08 < $\alpha = 0.05$, we can reject the null hypothesis.

Now consider the confidence interval:


In [34]:
# Differences:
stroopdata['Difference'] = stroopdata['Incongruent'] - stroopdata['Congruent']
# Sum of all differences:
sumdiff = sum(stroopdata['Difference'])
# Std of all differences:
stddiff = np.std(stroopdata['Difference'])
# Average of all sum differences:
avgdiff = sumdiff/24
# CI = avgdiff +- std(diff)/sqrt(n)
lower_bound = avgdiff - 2.064*stddiff/np.sqrt(24)
upper_bound = avgdiff + 2.064*stddiff/np.sqrt(24)

In [35]:
print(lower_bound)
print(upper_bound)


5.95833510498
9.97124822835

So with $\alpha = 0.05$, the confidence interval in this case is (5.958, 9.971).

We can reject the null hypothesis that there is no difference between the congruent and incongruent list, and conclude that the condition of the list does have an affect on the stimulus (reaction) time in the sample.

Further exploration:

One possible explation for the phenomenon is the association between the texts in the list and the colors of the texts, e.g., it would be easier for us to associate the text "blue" with the color blue, then the color red. For further explorations, we can design an experiment when the texts are just words that don't have any association with the colors, and see if the stimulus time is shorter.